package com.eight.cloud.payment.service.impl;

import com.eight.cloud.client.model.dto.PlatformOrderDto;
import com.eight.cloud.client.model.vo.OrderVo;
import com.eight.cloud.client.model.vo.RefundVo;
import com.eight.cloud.payment.common.enums.PayStrategyEnum;
import com.eight.cloud.payment.core.PaymentFactory;
import com.eight.cloud.payment.model.vo.SubPayOrderVo;
import com.eight.cloud.payment.model.vo.SubRefundOrderVo;
import com.eight.cloud.payment.service.IThirdPayService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @ClassName: ThirdPayServiceImpl
 * @Author: TXC
 * @Date: 2024-10-21 17:13
 **/
@Service
public class ThirdPayServiceImpl implements IThirdPayService {
    @Resource
    private PaymentFactory paymentFactory;

    @Override
    public String thirdPay(PayStrategyEnum payStrategyEnum, PlatformOrderDto order) {
        return paymentFactory.getPaymentService(payStrategyEnum).pay(order);
    }

    @Override
    public String refund(PayStrategyEnum payStrategyEnum, SubRefundOrderVo refundOrder, String notifyUrl) {
        return paymentFactory.getPaymentService(payStrategyEnum).refund(refundOrder, notifyUrl);
    }

    @Override
    public RefundVo queryByOutRefundNo(PayStrategyEnum payStrategyEnum, SubRefundOrderVo subRefundOrder) {
        return paymentFactory.getPaymentService(payStrategyEnum).queryByOutRefundNo(subRefundOrder);
    }

    @Override
    public OrderVo queryOrderById(PayStrategyEnum payStrategyEnum, SubPayOrderVo subPayOrder) {
        return paymentFactory.getPaymentService(payStrategyEnum).queryOrderById(subPayOrder);
    }

    @Override
    public OrderVo queryOrderByOutTradeNo(PayStrategyEnum payStrategyEnum, SubPayOrderVo subPayOrder) {
        return paymentFactory.getPaymentService(payStrategyEnum).queryOrderByOutTradeNo(subPayOrder);
    }

    @Override
    public String closeOrder(PayStrategyEnum payStrategyEnum, SubPayOrderVo subPayOrder) {
        return paymentFactory.getPaymentService(payStrategyEnum).closeOrder(subPayOrder);
    }
}
